import type { AddressItem, AddressParams } from '@/types/address'
import { http } from '@/utils/http'

/**
 * 添加收货地址
 * @param data 请求参数
 */
export const memberAddressAddAPI = (data: AddressParams) => {
  return http({
    method: 'POST',
    url: '/member-address',
    data,
  })
}

/**
 * 获取收货地址列表
 * @returns
 */
export const memberAddressListAPI = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member-address',
  })
}

/**
 * 根据id获取收货地址详情
 * @param id
 * @returns
 */
export const memberAddressDetailAPI = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: `/member-address/${id}`,
  })
}

/**
 *
 * @param id 路径参数
 * @param data 请求参数
 * @returns
 */
export const memberAddressUpdateAPI = (id: string, data: AddressParams) => {
  return http({
    method: 'PUT',
    url: `/member-address/${id}`,
    data,
  })
}

// 根据id删除收货地址
export const memberAddressDeleteAPI = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/member-address/${id}`,
  })
}
